package Day01_Reflect;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.io.FileNotFoundException;

public class ReflectTest {
    public static void main(String[] args) throws Exception {
//        写一个"框架",在不改变任何代码的前提下,可以创建任意类的对象,并调用其所有的方法
//        实现: 1、配置文件 2、反射
        /*Properties prop = new Properties();
        prop.put("罗宾宾",30);
        System.out.println(prop);*/
/*        FileInputStream fis = new FileInputStream("a.txt");
        FileOutputStream fos = new FileOutputStream("b.txt");
        int b;
        while((b = fis.read()) != -1){
            fos.write(b);
        }
        fis.close();
        fos.close();*/
        /*Properties prop = new Properties();
        prop.setProperty("name","罗宾宾");
        prop.setProperty("age","30");
        Enumeration<String> en =(Enumeration<String>) prop.propertyNames();
        while(en.hasMoreElements()){
            String key = en.nextElement();
            String value = prop.getProperty(key);
            System.out.println(key+"="+value);
        }*/
        Properties prop = new Properties();
        prop.load(new FileInputStream("config.properties"));
        prop.setProperty("age","20");
        prop.store(new FileOutputStream("config.properties"),null);
        System.out.println(prop);
    }
}
